#include "StdAfx.h"
#include ".\socketsession.h"
namespace Lumin {
namespace Win32 {

void *CSocketSession::operator new(size_t objectSize)
{
	return CPoolMgr<CSocketSession>::GetInstance()->Allocate(objectSize);
}

void CSocketSession::operator delete(void *pObject, size_t /* bufferSize*/)
{
	CPoolMgr<CSocketSession>::GetInstance()->Free(pObject);
}

CSocketSession::CSocketSession(DWORD dwContext):m_dwContext(dwContext),m_dwData(NULL)
{
}

CSocketSession::~CSocketSession(void)
{
}

void CSocketSession::Shutdown()
{
	if(IsConnected()){
		m_pConnection->Shutdown();
	}
}

BOOL CSocketSession::IsConnected()
{
	return (m_pConnection && m_pConnection->IsConnected());
}

void CSocketSession::SendPacket(const PACKET& packet)
{
	if(IsConnected()){
		m_pConnection->SendPacket(packet.GetSerializeStream());
	}
}


void CSocketSession::SetConnectionPtr(IConnection* pConnection)
{
	if(pConnection != NULL)
	{
		m_address = pConnection->GetAddress();
	}
	m_pConnection = pConnection;
}

}
}